<?php

$backend  = dirname(dirname(__FILE__));
$frontend = dirname($backend);

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
    'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
    'name'=>'My Web Application',

    // 自訂義 templates
    'viewPath' => $frontend.'/templates',

    // preloading 'log' component
    'preload'=>array('log'),

    // autoloading model and component classes
    'import'=>array(
        'application.components.*',
        'application.models.*',
        'application.models.userdata.*',
        'application.libraries.vendors.*',
        'application.libraries.net.*',
        'application.libraries.data.*',
        'application.libraries.date.*',
        'application.libraries.locale.*',
    ),

    'modules'=>array(
        // uncomment the following to enable the Gii tool
        /*
        'gii'=>array(
            'class'=>'system.gii.GiiModule',
            'password'=>'password',
            // If removed, Gii defaults to localhost only. Edit carefully to taste.
            'ipFilters'=>array('192.168.1.111','::1'),  // array('127.0.0.1','::1')
        ),
        */
    ),

    // application components
    'components'=>array(
        'user'=>array(
            // enable cookie-based authentication
            'allowAutoLogin'=>true,
        ),
        // uncomment the following to enable URLs in path-format
        /*
        'urlManager'=>array(
            'urlFormat'=>'path',
            'rules'=>array(
                '<controller:\w+>/<id:\d+>'=>'<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
                '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
            ),
        ),
        */
        'urlManager'=>array(
            'urlFormat'=>'path',
            'rules'=>array(
                // rule 規則 :: 當符合 '網址傳入的格式'                                         => 則呼叫特定程式碼的 'controller/action'
                // blog 
                '<controller:blog>/<blogKey:\w+>'                                               =>'<controller>/home',
                '<controller:blog>/<blogKey:\w+>/page/<pageId:\d+>'                             =>'<controller>/home',
                '<controller:blog>/<blogKey:\w+>/article/<articleId:\d+>'                       =>'<controller>/article',
                '<controller:blog>/<blogKey:\w+>/<action:\w+>'                                  =>'<controller>/<action>',
                '<controller:blog>/<blogKey:\w+>/<action:post>/<postId:\d+>'                    =>'<controller>/<action>',
                // member
                '<controller:member>/<action:form>/<where:\w+>'                                 =>'<controller>/<action>',
                '<controller:member>/<action:login>/<where:\w+>'                                =>'<controller>/<action>',
                // admin 
                '<controller:\w+>'                                                              =>'<controller>/index',
                '<controller:\w+>/list/<page:\d+>/'                                             =>'<controller>/list',
                '<controller:\w+>/list/<page:\d+>/<searchKey:\w+>'                              =>'<controller>/list',
                '<controller:\w+>/new'                                                          =>'<controller>/new',
                '<controller:\w+>/edit/<id:\d+>'                                                =>'<controller>/edit',
                // admin 子項目 
                '<controller:\w+>/<action:list\w+>/<parentId:\d+>'                              =>'<controller>/<action>',
                '<controller:\w+>/<action:list\w+>/<parentId:\d+>/<page:\d+>'                   =>'<controller>/<action>',
                '<controller:\w+>/<action:list\w+>/<parentId:\d+>/<page:\d+>/<searchKey:\w+>'   =>'<controller>/<action>',
                '<controller:\w+>/<action:new\w+>/<parentId:\d+>'                               =>'<controller>/<action>',
                '<controller:\w+>/<action:edit\w+>/<parentId:\d+>/<id:\d+>'                     =>'<controller>/<action>',
                // admin 編輯自己的設定 
                '<controller:\w+>/setting'                                                      =>'<controller>/setting',
                // admin 其它 
                '<controller:\w+>/<action:\w+>/<id:\d+>'                                        =>'<controller>/<action>',
//              '<controller:\w+>/<action:\w+>/<id:\d+>/<data2:\d+>'                            =>'<controller>/<action>',
            ),
        ),
        /*
        'db'=>array(
            'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
        ),
        */
        // uncomment the following to use a MySQL database
        'db'=>array(
            'connectionString' => 'mysql:host=localhost;dbname=test',
            'emulatePrepare' => true,
            'username' => 'webio',
            'password' => 'mysql.4.webio.password',
            'charset' => 'utf8',
        ),
        'errorHandler'=>array(
            // use 'site/error' action to display errors
            'errorAction'=>'site/error',
        ),
        'log'=>array(
            'class'=>'CLogRouter',
            'routes'=>array(
                array(
                    'class'=>'CFileLogRoute',
                    'levels'=>'error, warning',
                ),
                // uncomment the following to show log messages on web pages
                /*
                array(
                    'class'=>'CWebLogRoute',
                ),
                */
            ),
        ),

/*
        'viewRenderer'=>array(
            'class'         => 'application.extensions.yiiext.renderers.smarty.ESmartyViewRenderer',
            'fileExtension' => '.tpl',
          //'pluginsDir'    => 'application.smartyPlugins',
          //'configDir'     => 'application.smartyConfig',
        ),
        'viewRenderer' => array(
            'class' => 'CSmartyViewRenderer',
        ),
        'viewRenderer' => array(
            'class' => 'application.extensions.smarty.CSmartyViewRenderer',
        ),
*/
        'gmanager' => array(
            'class' => 'application.extensions.gmanager.GGmanager',
        ),

    ),

    // application-level parameters that can be accessed
    // using Yii::app()->params['paramName']
    'params'=>array(
        // this is used in contact page
        'adminEmail'=>'webmaster@example.com',
    ),


);